import java.util.concurrent.CountDownLatch;

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            int r = i;
            Thread t = new Thread(()->{
                System.out.println("第" + r +"个任务");
               count.countDown();
            });
            t.start();
        }
        count.await();
        System.out.println("任务结束");
    }
}
